package org.example.AI;

/**
 * @author: 默苍璃
 * @date: 2024-07-18 14:38
 */
// 同事类，即用户类
public class User {
    private String name;
    private ChatRoomMediator mediator;

    public User(String name, ChatRoomMediator mediator) {
        this.name = name;
        this.mediator = mediator;
        mediator.addUser(this); // 用户初始化时注册到中介者
    }

    public void send(String message) {
        System.out.println(name + " 发送了消息：" + message);
        mediator.sendMessage(message, this);
    }

    public void receive(String message) {
        System.out.println(name + " 接收到消息：" + message);
    }

}
